home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / src / ChunkyStartup2.lha / ChunkyStartup2K1 / ChunkyStartup.h < prev    next >
C/C++ Source or Header  |  2001-06-18  |  11KB  |  245 lines

  1. #ifndef K_CHUNKYSTARTUP_H
  2. #define K_CHUNKYSTARTUP_H
  3. /*==========================================================*/
  4. /*====                                                  ====*/
  5. /*====                                                  ====*/
  6. /*====      ChunkyStartup.h => Chunkystartup.o handler  ====*/
  7. /*====      krabob@online.fr 23/04/2001                  ====*/
  8. /*====                                                  ====*/
  9. /*====                                                  ====*/
  10. /*==========================================================*/
  11. /*
  12.     .o containing simple functions very needed to code 8bit demos,
  13.     fully AGA-CGX (graphic card) compatible, usable in C
  14.     or asm, compatible since 68020.
  15.     Everything needed to code nice demos is here:
  16.  
  17.     8bit screen opening at any resolution.
  18.     real aga-cgx stable 50Hz clock (using timer.device),
  19.  
  20.     See test.c for an example of use.
  21.  
  22.     This .h was designed for vbcc (68k) that means
  23.     the primitives use the __reg("d0") syntax to notify
  24.     what argument use what register:
  25.     This syntax is not the same for other compiler
  26.     -> just change that to fit your compiler.
  27.  
  28.     every extern function stack their regs correctly.
  29.  
  30.     this .o does not use fpu and should be compatible since 68020.
  31.     it was tested with muforce: no enforce hits.
  32.  
  33. */
  34.  
  35. /* Amiga-Standard Types */
  36. #include    <exec/types.h>
  37.  
  38. /* structure for screen, window */
  39. #include    <intuition/screens.h>
  40. #include    <intuition/intuition.h>
  41. /*==========================================================*/
  42. /*====                                                  ====*/
  43. /*====      ChunkyStartupInit  -  ChunkyStartupClose    ====*/
  44. /*====                                                  ====*/
  45. /*==========================================================*/
  46. extern  __reg("d0") int         ChunkyStartupInit(
  47.                                     __reg("d0")int Width,
  48.                                     __reg("d1")int Height
  49.                                                 );
  50.  
  51. extern  void                    ChunkyStartupClose(void);
  52. /*
  53.     This one should be launch one time at the very beginning
  54.     of the main;
  55.  
  56.     you only provide Width and Height, intuition is used to
  57.     find the best mode possible. IF Width=0 then Height is ignored,
  58.     and an ASL screen requester ask a mode to the user.
  59.     in that case, screen resolution will be variable (see below)
  60.     ( don't try too funny resolution !! CGX only support "square"
  61.     resolutions on most hardwares. Width must also be multiple of 32. )
  62.  
  63.     It opens these library:  Intuition,asl,graphics,cybergraphics if present,
  64.     and the timer device (for synchro)
  65.  
  66.     Then it opens the screen, with triple  buffer under aga.
  67.     (aga is used if no cgx libs is found.)
  68.  
  69.     Return !=0 if succesful. If the value returned is 0, it failed.
  70.     From the moment it has been launch succesfully,
  71.     you can read the Width and Height of the screen in the global vars:
  72.  
  73.     ScreenWidth and ScreenHeight
  74.  
  75.     You can use theses value to alloc your own chunky buffer
  76.     ScreenWidth * ScreenHeight sized ! or maybe you could use:
  77.     UBYTE *Allocatechunkyforscreen() that do the same thing with
  78.     a buffer auto-freed when closing.
  79.  
  80.     To draw your chunk in the screen simply use in your loop(s):
  81.  
  82.     ScreenRefresh( ChunkyBuffer );
  83.  
  84.     when you USE ChunkyStartupInit(...) you must end your program
  85.     by ChunkyStartupClose(); Even if ChunkyStartupInit failed.
  86.     it will de-alloc and close back everything opened by the init
  87.     and everything done by this .o functions.
  88.  
  89. */
  90. /*==========================================================*/
  91. /*====                                                  ====*/
  92. /*====      Allocate Chunky for screen                  ====*/
  93. /*====                                                  ====*/
  94. /*==========================================================*/
  95. extern  UBYTE                   *Allocatechunkyforscreen(void );
  96. /*
  97.     since the screen can be "resolution-free",this function
  98.     automatically allocate a chunky buffer with the right size.
  99.     This buffer is safe to be passed to ScreenRefresh(...)
  100.     the dimension of the screen can be read in global vars
  101.     ScreenWidth & ScreenHeight.
  102.     This function can be used to open multiple buffers.
  103.     all buffers opened by that functions will be freed by
  104.     ChunkyStartupClose().
  105. */
  106. /*==========================================================*/
  107. /*====                                                  ====*/
  108. /*====      ListenEnd                                   ====*/
  109. /*====                                                  ====*/
  110. /*==========================================================*/
  111. extern  int                     ListenEnd();
  112. /*
  113.     ListenEnd use the screen's intuition port also available
  114.     in the Window structure given with global var "TheWindow"
  115.     to check for the 2 mouse buttons + the escape key.
  116.     if one is pressed, it returns != 0. if nothing is pressed,
  117.     it returns 0 immediately. Nice to test for exit !
  118. */
  119. /*==========================================================*/
  120. /*====                                                  ====*/
  121. /*====      ScreenRefresh                               ====*/
  122. /*====                                                  ====*/
  123. /*==========================================================*/
  124. extern  void                    ScreenRefresh(
  125.                                     __reg("a0") UBYTE * ScreenBuffer
  126.                                             );
  127. /*
  128.     Simply draw the 8bitperpixel chunk to the screen
  129.     and make it appear. seems to be safe. triple buffer performed
  130.     under aga (so it takes a lot of chipmem if 640*512)
  131. */
  132. /*==========================================================*/
  133. /*====                                                  ====*/
  134. /*====      SetScreenPalette                            ====*/
  135. /*====                                                  ====*/
  136. /*==========================================================*/
  137. extern  void                    SetScreenPalette(
  138.                                     __reg("a0") ULONG *Table
  139.                                             );
  140. /*
  141.     Simply set a palette for the screen.
  142.     this function use Graphics/LoadRGB32,
  143.     and the palette format must be RGB32 (see graphics.doc)
  144.  
  145.         The format of the table passed to this function is a series of records,
  146.         each with the following format:
  147.  
  148.                 1 Word with the number of colors to load
  149.                 1 Word with the first color to be loaded.
  150.                 3 longwords representing a left justified 32 bit rgb triplet.
  151.                 The list is terminated by a count value of 0.
  152.  
  153.            examples:
  154.                 ULONG table[]={1l<<16+0,0xffffffff,0,0,0} loads color register
  155.                         0 with 100% red.
  156.                 ULONG table[]={256l<<16+0,r1,g1,b1,r2,g2,b2,.....0} can be used
  157.                         to load an entire 256 color palette.
  158.  
  159.         Lower order bits of the palette specification will be discarded,
  160.         depending on the color palette resolution of the target graphics
  161.         device. Use 0xffffffff for the full value, 0x7fffffff for 50%,
  162.         etc. You can find out the palette range for your screen by
  163.         querying the graphics data base.
  164. */
  165. /*==========================================================*/
  166. /*====                                                  ====*/
  167. /*====      ResetTaskTime                               ====*/
  168. /*====                                                  ====*/
  169. /*==========================================================*/
  170. extern  void                    ResetTaskTime( void );
  171. /*
  172.     Simply set to 0 the inner clock provided by ChunkyStartupInit(...)
  173.     It is already launch by this init. only needed if you want time
  174.     to be reseted.
  175. */
  176. /*==========================================================*/
  177. /*====                                                  ====*/
  178. /*====      GetTaskTime                                 ====*/
  179. /*====                                                  ====*/
  180. /*==========================================================*/
  181. extern  __reg("d0") int         GetTaskTime( void );
  182. /*
  183.     Return a int value representing the time since the
  184.     launch of ChunkyStartupInit(...) with units of 1/50 seconds.
  185.     it means 100 stands for 2 seconds.
  186.     timer.device/UNIT_MICROHZ based clock.
  187.     (WaitTOF was not safe at all for cgx,and AGA could be NTSC.)
  188.     so I myself use this function to synchronize the cinematics
  189.     of my demos, with no other "synchro" task.
  190. */
  191. /*==========================================================*/
  192. /*====                                                  ====*/
  193. /*====      Chunkystartup's own AllocRmb                ====*/
  194. /*====                                                  ====*/
  195. /*==========================================================*/
  196. extern  __reg("d0") UBYTE * AllocRmb( __reg("d0") int size );
  197. /*
  198.     (Act a bit like intuition's allocremember)
  199.     allocate a buffer "size" bytes long and return
  200.     a pointer on the chunk.
  201.     the buffer returned will be automatically freed by
  202.     ChunkyStartupClose();
  203. */
  204. /*==========================================================*/
  205. /*====                                                  ====*/
  206. /*====      Chunkystartup's own LoadRmb                 ====*/
  207. /*====                                                  ====*/
  208. /*==========================================================*/
  209. struct CSAllocCell
  210. {
  211.         int      csac_private1;
  212.         int      csac_private2;
  213.         int      csac_ChunkSize;
  214.         UBYTE   *csac_Buffer;
  215. };
  216.  
  217. extern  __reg("d0") struct CSAllocCell * LoadRmb( __reg("a0") STRPTR);
  218. /*
  219.     allocate a buffer and load a file in.
  220.     STRPTR is a 0-ended string which indicate a dos file.
  221.     you can then access the buffer with csac_Buffer
  222.     and take its size with csac_ChunkSize.
  223.  
  224.     the structure & buffer returned will be automatically freed by
  225.     ChunkyStartupClose();
  226. */
  227.  
  228. /*==========================================================*/
  229. /*====                                                  ====*/
  230. /*====      Some useful global vars                     ====*/
  231. /*====                                                  ====*/
  232. /*==========================================================*/
  233. extern  int                     ScreenWidth;    /* READ ONLY ! */
  234. extern  int                     ScreenHeight;
  235.  
  236.  
  237. extern  STRPTR                  Exitmessage;    /* a string or NULL for esayrequest while quitting */
  238.                                                 /* set this before ChunkyStartupClose  */
  239.  
  240. extern  struct  Screen                  *TheScreen;     /* the intuition screen*/
  241. extern  struct  Window                  *TheWindow;
  242.  
  243. #endif  /* K_CHUNKYSTARTUP_H */
  244.  
  245.